import java.util.Scanner;

/**
 * 计算日期到天数转换
 *
 *根据输入的日期，计算是这一年的第几天。
 * 保证年份为4位数且日期合法。
 */
public class HJ73 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] months = new int[]{31,28,31,30,31,30,31,31,30,31,30,31};
        while (scanner.hasNext()){
            String s = scanner.nextLine();
            String[] s1 = s.split(" ");
            int year = Integer.parseInt(s1[0]);
            int month = Integer.parseInt(s1[1]);
            int day = Integer.parseInt(s1[2]);

            int sum = 0;
            for (int i = 1; i < month; i++) {
                sum+=months[i-1];
            }
            int res = sum+day;
            if(month > 2 && isLeapYear(year)){
               res += 1;
            }
            System.out.println(res);
        }
    }

    private static boolean isLeapYear(int year) {
        if(year%4==0 && year%100!=0 || year%400==0){
            return true;
        }
        return false;
    }
}
